package com.cdut.logistics.action.system;

import java.util.List;

import com.cdut.logistics.model.entity.system.User;

import org.w3c.dom.Attr;

import com.cdut.logistics.service.impl.system.UserServiceImp;
import com.cdut.logistics.service.interf.system.UserService;
import com.cdut.logistics.model.dao.system.userDAO;
import com.jfinal.core.Controller;
import com.jfinal.aop.Before;

/**
 * @ClassName: UserController  
 * @Description: TODO(用户类的action)  
 * @author lxh
 * @date 2018年1月28日 下午2:29:04
 */
public class UserController extends Controller {
	 UserServiceImp user= new UserServiceImp();
//	Id
//	Name
//	Identity
//	student_id
//	school_id
//	academy_id
//	dorm_id
//	major_id
//	Sex
//	role_id
//	Rep_id

	/**
	 * 
	 * @Title: register  
	 * @Description: TODO(新增用户)
	 * @author lxh
	 * @throws
	 */
	public void register(){
		String username=getPara("username");
		String password=getPara("password");
		String identity=getPara("identity");
		String student_id=getPara("student_id");
		String school_id=getPara("school_id");
		String academy_id=getPara("academy_id");
		String dorm_id=getPara("dorm_id");
		String major_id=getPara("major_id");
		String sex=getPara("sex");
		String role_id=getPara("role_id");
		String rep_id=getPara("rep_id");
		String is_use="1";
		String active="1";
		boolean result=user.add(username, password,identity,student_id,school_id,
				academy_id,dorm_id,major_id,sex,role_id,rep_id,is_use,active);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * @Title: deleteUser  
	 * @Description: TODO(逻辑删除用户)
	 * @author lxh
	 * @throws
	 */
	public void deleteUser(){
		String id=getPara("id");
		boolean result=user.DeleteUser(id);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * @Title: queryUserInfo  
	 * @Description: TODO(查询用户信息)
	 * @author lxh
	 * @throws
	 */
	public void queryUserInfo(){
		String id=getPara("id");
		User result=user.QueryUserInfo(id);
		setAttr("result", result);
		renderJson();
	}
	/**
	 * 
	 * @Title: updateUserInfo  
	 * @Description: TODO(修改用户信息)
	 * @author lxh
	 * @throws
	 */
	public void updateUserInfo(){
		String username=getPara("username");
		String password=getPara("password");
		String identity=getPara("identity");
		String id=getPara("id");
		String student_id=getPara("student_id");
		String school_id=getPara("school_id");
		String academy_id=getPara("academy_id");
		String dorm_id=getPara("dorm_id");
		String major_id=getPara("major_id");
		String sex=getPara("sex");
		String role_id=getPara("role_id");
		String rep_id=getPara("rep_id");
		boolean result=user.UpdateUser(username,password,identity,student_id,school_id,academy_id,
				dorm_id,major_id,sex,role_id,rep_id,id);
		setAttr("result",result);
		renderJson();
	}
}	
	
